always resize the popup when it is visible, popdown when there are less
authorKristian Rietveld <kris@gtk.org>
Wed, 19 Nov 2003 21:26:27 +0000 (21:26 +0000)
committerKristian Rietveld <kristian@src.gnome.org>
Wed, 19 Nov 2003 21:26:27 +0000 (21:26 +0000)
Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>

* gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
the popup when it is visible, popdown when there are less chars
than the minimum key length in the entry,
(gtk_entry_completion_changed): popdown when the entry is empty.

* gtk/gtkentrycompletion.c (gtk_entry_completion_init): set the
size request of the vscrollbar to (-1, 0), to get a nicely sized
completion treeview (Fixes #126573, reported by Piers Cornwell),
(_gtk_entry_completion_resize_popup): show/hide the action_view
based on items.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkentry.c
gtk/gtkentrycompletion.c

index c18a4850d84d84580e25a9a8b4cbd85a84c90c09..b63d14a88ab8e1faf20490ca319c02bdcfc6f33b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
+       the popup when it is visible, popdown when there are less chars
+       than the minimum key length in the entry,
+       (gtk_entry_completion_changed): popdown when the entry is empty.
+
+       * gtk/gtkentrycompletion.c (gtk_entry_completion_init): set the
+       size request of the vscrollbar to (-1, 0), to get a nicely sized
+       completion treeview (Fixes #126573, reported by Piers Cornwell),
+       (_gtk_entry_completion_resize_popup): show/hide the action_view
+       based on items.
+
 2003-11-19  Federico Mena Quintero  <federico@ximian.com>
 
        * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_init): Turn
index c18a4850d84d84580e25a9a8b4cbd85a84c90c09..b63d14a88ab8e1faf20490ca319c02bdcfc6f33b 100644 (file)
@@ -1,3 +1,16 @@
+Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
+       the popup when it is visible, popdown when there are less chars
+       than the minimum key length in the entry,
+       (gtk_entry_completion_changed): popdown when the entry is empty.
+
+       * gtk/gtkentrycompletion.c (gtk_entry_completion_init): set the
+       size request of the vscrollbar to (-1, 0), to get a nicely sized
+       completion treeview (Fixes #126573, reported by Piers Cornwell),
+       (_gtk_entry_completion_resize_popup): show/hide the action_view
+       based on items.
+
 2003-11-19  Federico Mena Quintero  <federico@ximian.com>
 
        * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_init): Turn
index c18a4850d84d84580e25a9a8b4cbd85a84c90c09..b63d14a88ab8e1faf20490ca319c02bdcfc6f33b 100644 (file)
@@ -1,3 +1,16 @@
+Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
+       the popup when it is visible, popdown when there are less chars
+       than the minimum key length in the entry,
+       (gtk_entry_completion_changed): popdown when the entry is empty.
+
+       * gtk/gtkentrycompletion.c (gtk_entry_completion_init): set the
+       size request of the vscrollbar to (-1, 0), to get a nicely sized
+       completion treeview (Fixes #126573, reported by Piers Cornwell),
+       (_gtk_entry_completion_resize_popup): show/hide the action_view
+       based on items.
+
 2003-11-19  Federico Mena Quintero  <federico@ximian.com>
 
        * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_init): Turn
index c18a4850d84d84580e25a9a8b4cbd85a84c90c09..b63d14a88ab8e1faf20490ca319c02bdcfc6f33b 100644 (file)
@@ -1,3 +1,16 @@
+Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
+       the popup when it is visible, popdown when there are less chars
+       than the minimum key length in the entry,
+       (gtk_entry_completion_changed): popdown when the entry is empty.
+
+       * gtk/gtkentrycompletion.c (gtk_entry_completion_init): set the
+       size request of the vscrollbar to (-1, 0), to get a nicely sized
+       completion treeview (Fixes #126573, reported by Piers Cornwell),
+       (_gtk_entry_completion_resize_popup): show/hide the action_view
+       based on items.
+
 2003-11-19  Federico Mena Quintero  <federico@ximian.com>
 
        * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_init): Turn
index c18a4850d84d84580e25a9a8b4cbd85a84c90c09..b63d14a88ab8e1faf20490ca319c02bdcfc6f33b 100644 (file)
@@ -1,3 +1,16 @@
+Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
+       the popup when it is visible, popdown when there are less chars
+       than the minimum key length in the entry,
+       (gtk_entry_completion_changed): popdown when the entry is empty.
+
+       * gtk/gtkentrycompletion.c (gtk_entry_completion_init): set the
+       size request of the vscrollbar to (-1, 0), to get a nicely sized
+       completion treeview (Fixes #126573, reported by Piers Cornwell),
+       (_gtk_entry_completion_resize_popup): show/hide the action_view
+       based on items.
+
 2003-11-19  Federico Mena Quintero  <federico@ximian.com>
 
        * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_init): Turn
index 8f97dcf5944c8534dab8ac21d03997d69631be00..b4dae1f31c5bd36db95084ec37c719f9cb9491d7 100644 (file)
@@ -4514,14 +4514,14 @@ gtk_entry_completion_timeout (gpointer data)
 
       actions = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->actions), NULL);
 
-      if (matches > 0 || actions > 0)
-        {
-          if (! GTK_WIDGET_MAPPED (completion->priv->popup_window))
-            _gtk_entry_completion_popup (completion);
-          else
-            _gtk_entry_completion_resize_popup (completion);
-        }
+      if ((matches > 0 || actions > 0)
+          && ! GTK_WIDGET_VISIBLE (completion->priv->popup_window))
+        _gtk_entry_completion_popup (completion);
+      else if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
+        _gtk_entry_completion_resize_popup (completion);
     }
+  else if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
+    _gtk_entry_completion_popdown (completion);
 
   GDK_THREADS_LEAVE ();
 
@@ -4682,7 +4682,11 @@ gtk_entry_completion_changed (GtkWidget *entry,
 
   /* no need to normalize for this test */
   if (! strcmp ("", gtk_entry_get_text (GTK_ENTRY (entry))))
-    return;
+    {
+      if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
+        _gtk_entry_completion_popdown (completion);
+      return;
+    }
 
   completion->priv->completion_timeout =
     g_timeout_add (COMPLETION_TIMEOUT,
index 2dc0896b277767285cdb1febcc2de3e4602739b9..de8664e5202efa293a52c363a2ddbb0ae9a68bb0 100644 (file)
@@ -258,6 +258,8 @@ gtk_entry_completion_init (GtkEntryCompletion *completion)
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolled_window),
                                        GTK_SHADOW_ETCHED_IN);
 
+  /* a nasty hack to get the completions treeview to size nicely */
+  gtk_widget_set_size_request (GTK_SCROLLED_WINDOW (priv->scrolled_window)->vscrollbar, -1, 0);
 
   /* actions */
   priv->actions = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
@@ -1061,6 +1063,8 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
 
   if (items)
     {
+      gtk_widget_show (completion->priv->action_view);
+
       gtk_tree_view_column_cell_get_size (gtk_tree_view_get_column (GTK_TREE_VIEW (completion->priv->action_view), 0),
                                           NULL, NULL, NULL, NULL,
                                           &height);
@@ -1069,6 +1073,8 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
                                    completion->priv->entry->allocation.width - 2 * x_border,
                                    items * height);
     }
+  else
+    gtk_widget_hide (completion->priv->action_view);
 
   return height;
 }